package com.lcxw.hxzbapi.tencentim.controller;

import com.alibaba.fastjson.JSONObject;
import com.lcxw.hxzbapi.tencentim.common.TencentImConfig;
import com.lcxw.hxzbapi.entity.response.Response;
import com.tencentyun.TLSSigAPIv2;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user/sig")
public class UserSignController {

    @Resource
    private TencentImConfig configBean;


    @PostMapping("/get")
    public Response getUserSig(@RequestBody JSONObject requestParam) {

        TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(configBean.getAppid(), configBean.getKey());
        String userId = requestParam.getString("userId");
        String data = tlsSigAPIv2.genSig(userId,configBean.getExpire());
        return Response.ok(data);
    }
}
